#include "FileKey.h"

FileKey::FileKey()
{

}

FileKey::FileKey(QString fileName, QHostAddress addr, Mode mode)
{
	_fileName = fileName;
	_addr = addr;
	_mode = mode;
}

FileKey::~FileKey()
{

}

void FileKey::Set(QString fileName, QHostAddress addr, Mode mode)
{
	_fileName = fileName;
	_addr = addr;
	_mode = mode;
}

void FileKey::Set(FileKey &key)
{
	Set(key.GetFileName(), key.GetAddress(), key.GetMode());
}

QString FileKey::GetFileName() const
{
	return _fileName;
}

QHostAddress FileKey::GetAddress() const
{
	return _addr;
}

Mode FileKey::GetMode() const
{
	return _mode;
}

bool FileKey::operator<(const FileKey &right) const
{
//	result = (_fileName < right._fileName ||
//			  (_fileName == right._fileName && _addr.toString() < right._addr.toString()));
//	result &= (_mode < right._mode);

	if (_fileName < right._fileName)
		return true;
	else if (_fileName == right._fileName)
	{
		if (_addr.toIPv4Address() < right._addr.toIPv4Address())
			return true;
		else if (_addr.toIPv4Address() == right._addr.toIPv4Address() &&
				 _mode < right._mode)
		{
			return true;
		}
	}
	return false;
}

void FileKey::operator=(const FileKey &right)
{
	_fileName = right._fileName;
	_addr = right._addr;
	_mode = right._mode;
}
